﻿using Brc_PaaS.Common.Model.Basic;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;

namespace Brc_PaaS.Api.Common
{
    /// <summary>
    /// 基础控制器
    /// </summary>
    [ApiController]
    public class AdminBaseController : ControllerBase
    {
        /// <summary>
        /// 配置读取接口
        /// </summary>
        private readonly IConfiguration configuration;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="configuration"></param>
        public AdminBaseController(IConfiguration configuration)
        {
            this.configuration = configuration;
        }
        private string accountId = string.Empty;

        /// <summary>
        /// 账户Id
        /// </summary>
        protected string AccountId
        {
            get
            {
                if (string.IsNullOrEmpty(accountId))
                {
                    accountId = HttpContext.Items["AccountId"] != null ? HttpContext.Items["AccountId"].ToString() : string.Empty;
                }
                return accountId;
            }
        }

        /// <summary>
        /// PaaS平台Redis配置实体
        /// </summary>
        protected RedisServerEntity RedisServerEntity
        {
            get
            {
                return configuration.GetSection("RedisConfiguration").Get<RedisServerEntity>();
            }
        }
    }

}

